#include<bits/stdc++.h>
using namespace std;
int n,a[200005];
bool vis[200005];//false-->red  true->blue
int maxn;
void check(){
    int pre[200005];
    int lst_red=0,lst_blue=0;
    for(int i=1;i<=n;i++){
        //cout << vis[i];
        if(vis[i]){
            pre[i]=lst_blue;
            lst_blue=i;
        }
        else{
            pre[i]=lst_red;
            lst_red=i;
        }
    }
    int sum=0;
    for(int i=1;i<=n;i++){
        if(pre[i]!=0 && a[i]==a[pre[i]]){
            sum+=a[i];
        }
    }
    //cout << endl;
    maxn=max(maxn,sum);
    return;
}
void dfs(int now){
    if(now>n){
        check();
        return;
    }
    vis[now]=false;
    dfs(now+1);
    vis[now]=true;
    dfs(now+1);
    return;
}
void f(){
    cin >> n;
    set<int> st;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        st.insert(a[i]);
    }
    if((int)(st.size())==n){
        cout << 0 << endl;
        return;
    }
    maxn=INT_MIN;
    memset(vis,false,sizeof(vis));
    dfs(1);
    cout << maxn << endl;
    return;
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t;
    cin >> t;
    while(t--)  f();
    return 0;
}
